package com.fomky.queried.plugin.common;

import lombok.Builder;

import java.time.Duration;


public abstract class AbstractConnectPlugin implements ConnectPlugin {


    protected Long startTime = System.currentTimeMillis();

    protected Long lastUseTime = System.currentTimeMillis();

    protected Duration timeout = Duration.ofHours(12);

    @Override
    public void updateUseTime() {
        this.lastUseTime = System.currentTimeMillis();
    }

    @Override
    public boolean isTimeout() {
        // 12h
        return Duration.ofMillis((System.currentTimeMillis() - this.lastUseTime)).getSeconds() > timeout.getSeconds();
    }

}
